package com.itheima.test6;

import java.io.*;
import java.net.Socket;
import java.util.UUID;

public class Test {
    public static void main(String[] args) throws IOException {
        Socket socket = new Socket("127.0.0.1", 10000);
        //网络写
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
        //本地读
        BufferedReader br = new BufferedReader(new FileReader("day16\\a.txt"));
        String line;
        while ((line = br.readLine()) != null) {
            bw.write(line);
        }
        bw.flush();
        socket.shutdownOutput();

        //网络读
        BufferedReader brr = new BufferedReader(new InputStreamReader(socket.getInputStream()));
        //本地写
        // BufferedWriter bww=new BufferedWriter(new FileWriter("day16\\"+ UUID.randomUUID().toString()+".txt"));
        String lin;
        while ((lin = brr.readLine()) != null) {
            System.out.println(lin);
        }

        br.close();
        socket.close();
    }
}
